<%@page import="com.google.appengine.api.datastore.EntityNotFoundException"%>
<%@page import="com.google.appengine.api.datastore.Query.FilterOperator"%>
<%@page import="com.google.appengine.api.datastore.DatastoreService" %>
<%@page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
<%@page import="com.google.appengine.api.datastore.Entity" %>
<%@page import="com.google.appengine.api.datastore.Key" %>
<%@page import="com.google.appengine.api.datastore.KeyFactory" %>
<%@page import="com.google.appengine.api.datastore.Query" %>
<%@page import="com.google.appengine.api.datastore.FetchOptions" %>
<%@page import="java.util.List" %>
<%@page import="java.util.ArrayList" %>

<%@page import="nl.project.data.Student" %>

<html>
	<body>
		<%
			DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
			//Key parentsKey = KeyFactory.createKey("Parents", "Parents");
			//Key parentsKey = KeyFactory.createKey("Students", "Students");
			//Key parentsKey = KeyFactory.createKey("Employees", "Employees");
			//Query query = new Query("Student", parentsKey).addFilter("parentId", FilterOperator.EQUAL, "1111");
			//Query query = new Query("Parent", parentsKey).addSort("parentId", Query.SortDirection.DESCENDING);
			//Query query = new Query("Student", parentsKey).addSort("studentId", Query.SortDirection.DESCENDING);
			//Query query = new Query("Parent", parentsKey).addFilter("parentID", FilterOperator.EQUAL, 1111);
			//Query query = new Query("Employee", parentsKey).addSort("employeeId", Query.SortDirection.DESCENDING);
			List<Entity> parents = datastore.prepare(query).asList(FetchOptions.Builder.withDefaults());
			//Entity parents = datastore.prepare(query).asSingleEntity();
			
			for (Entity parent : parents) {
				Object[] arr = parent.getProperties().keySet().toArray();
				for (int i = 0; i < arr.length; i++) {
					out.print(arr[i] + " ");
				}
				out.print(parent.getProperty("employeeId") + " ");
				out.print(parent.getProperty("password") + " ");
// 				out.print(parent.getProperty("parentId") + " ");
// 				out.print(parent.getProperty("title") + " ");
// 				out.print(parent.getProperty("zipCode") + " ");
// 				out.print(parent.getProperty("initials") + "<br>");
				/*
				Query query2 = new Query("vak").addSort("courseCode", Query.SortDirection.DESCENDING);
				query2.setAncestor(parent.getKey());
				
				List<Entity> vakken = datastore.prepare(query2).asList(FetchOptions.Builder.withDefaults());*/
				/*
				for (Entity vak : vakken) {
					out.print(vak.getProperty("courseCode") + " ");
					out.print(vak.getProperty("courseName") + " ");
					out.print(vak.getProperty("theacherName") + " ");
					out.print(vak.getProperty("theacherCode") + " ");
					out.print(vak.getProperty("classCode") + " ");
					out.print(vak.getProperty("theacherMailBoxNumber") + " ");
					out.print(vak.getProperty("theacherEmail") + " ");
				}
				*/
				//out.print(parent.getProperty("password") + "<br>");
			}
			
			out.print("Size: " + parents.size() + "<br>");
			//out.print("Size: " + parents.getProperty("password") + "<br>");
		%>
	</body>
</html>